<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>jstests thesis</title>
    </head>
    <body id="body">
		<div id="container">
			<p onclick="alert(this.id);" id="tag1">value1</p>

			<p id="tag2">value2</p>
		</div>
		<div id="content" class="lol">
			<p>content example</p>
		</div>
		<div class="lol">
			<ul id="successlist" style="color:#1D1;" />
			

		</div>
<script type="text/javascript">function AssertError(message) {
    this.name = "AssertError";
    this.message = message || "Assertion failed";
}
AssertError.prototype = new Error();
AssertError.prototype.constructor = AssertError;

/*
 * assertEq(actual, expected [, message])
 *   Throw if the two arguments are not the same.  The sameness of two values
 *   is determined as follows.  If both values are zero, they are the same iff
 *   their signs are the same.  Otherwise, if both values are NaN, they are the
 *   same.  Otherwise, they are the same if they compare equal using ===.
 * see https://bugzilla.mozilla.org/show_bug.cgi?id=480199 and
 *     https://bugzilla.mozilla.org/show_bug.cgi?id=515285
 */
var assertEquals =
    function (actual, expected, message)
    {
      function SameValue(v1, v2)
      {
        if (v1 === 0 && v2 === 0)
          return 1 / v1 === 1 / v2;
        if (v1 !== v1 && v2 !== v2)
          return true;
        return v1 === v2;
      }
      if (!SameValue(actual, expected))
      {
        throw new AssertError('Assertion failed: got "' + actual + '", expected "' + expected +
                            (message ? ": " + message : ""));
      }
    };

function assertTrue(actual) {
    assertEquals(actual, true);
}

function assertFalse(actual) {
    assertEquals(actual, false);
}
function success(method)
{
	var newli = document.createElement("li");
	newli.appendChild(document.createTextNode("method "+method+ " passed.."));
        alert(newli.textContent);
	document.getElementById("successlist").appendChild(newli);
}
</script>
<script type="text/javascript">
function SamObj()
{
	this.testdoc = function(){return Boolean(document === window.document);};
}

function testOnclick()
{
	var el = document.getElementById("linkedit");
	el.href = "#check";
	el.onclick= function(){
		alert('sexytime');return false; // works in IE and FF, not in spidermonkey
	}
	return false;
}
function testJQ()
{

	alert(document.firstChild.nextSibling);
	return false;
	var arInputs = document.getElementsByTagName("input");
	var inputVals = [];
	for (var elmInput in arInputs) {
		inputVals.push(arInputs[elmInput].value);
	}
	alert(inputVals);
	return false;
	var s = new SamObj();
	alert(s.testdoc());
	// jQuery +- line 5000 fails
	// jQuery xhr fails, known issue
	alert(jQuery("body").html());
	alert("t2: "+s.testdoc());
	var list = jQuery("#successlist").toArray();
	for(var i in list)
	{
		alert(list[i]);
	}
	return false;
}
// testing some object functionality
try{
	var objname = "my object",secondname = "proto";
	function TestObj()
	{
		this.name = objname;
		this.getName = function(){return this.name;};
	}
	function ProtoTestObj()
	{
		this.secondname = secondname;
		this.getName = function(){return this.name+" "+this.secondname;};
	}
	var myobj = new TestObj();
	assertEquals(myobj.name,objname);
	assertEquals(myobj.name,myobj["name"]); // syntax test
	success("object.property");
	assertEquals(myobj.getName(),objname); // testing a simple function of a selfmade object
	success("object.function");
	TestObj.prototype.name = objname+"2";	// changing the prototype property name
	TestObj.prototype.getName = function(){return "test";};	// changing the prototype function for a TestObj
	var myobj2 = new TestObj();
	assertEquals(myobj2.name,objname);
	delete(myobj2.name);
	assertEquals(myobj2.name,objname+"2");
	success("object.prototype.property");
	assertEquals(myobj2.getName(),objname+"2");	// check that the original function is executed instead of the prototype function
	delete(myobj2.getName);
	assertEquals(myobj2.getName(),"test");		// check that the deleted function is covered by the prototype function
	assertEquals(myobj2.name,myobj2["name"]);	// syntax test 2
	success("object.prototype.function");
	TestObj.prototype = new ProtoTestObj();
	var myobj3 = new TestObj();
	assertEquals(myobj3.secondname,secondname);
	assertFalse(myobj3.hasOwnProperty("secondname"));
	assertTrue(myobj3.hasOwnProperty("name"));
	success("object.hasOwnProperty");
	assertFalse(TestObj.hasOwnProperty("secondname"));
	assertFalse(ProtoTestObj.hasOwnProperty("secondname"));
	assertTrue(TestObj.prototype.hasOwnProperty("secondname"));
	success("object.prototype.hasOwnProperty");
	assertEquals(myobj3.getName(),objname);
	delete(myobj3.getName);
	assertEquals(myobj3.getName(),objname+" "+secondname);
	success("object.prototype.function (2)");
} catch(e) {
	alert(e.name + ": " + e.message);
}
	// variant of the element.textContent method
	// called by getText(element.childNodes) @TEST
	function getText( elems ){
		var ret = "", elem;
		// werkt wel
			// for ( var i = 0; i < elems.length; i++ )
			// for ( var i in elems )
		// werkt niet
			// for ( var i = 0; elems[i]; i++ )
		for ( var i = 0; elems[i]; i++ )
		{
			elem = elems[i];
			// Get the text from text nodes and CDATA nodes
			if ( elem.nodeType === 3 || elem.nodeType === 4 ) {
				ret += elem.nodeValue;

			// Traverse everything else, except comment nodes
			} else if ( elem.nodeType !== 8 ) {
				ret += getText( elem.childNodes );
			}
		}
		return ret;
	}
try{
	var test="lol";
	//assertEquals(test[0],"l");
	//success("stringarray"); FAILS IN IE TO, may be ignored I suppose
} catch(e) {
	alert(e.name + ": " + e.message);
}
</script>		<a href="#" id="linkedit">linktest</a>
		<input type="button" value="test" onclick="alert(Boolean(document.getElementById('successlist')));"/>
		<input type="button" value="test2" onclick="alert(getText(document.getElementById('successlist').childNodes));"/>
	</body>
</html>

